#ifndef QPROJECTMODEL_H
#define QPROJECTMODEL_H

#include <QAbstractItemModel>
#include "projectmodel.h"


/***
 * 对应的是一个树形模型.
 *  QAbstractItemModel 在我的世界里就是一个DataSource,用来存放所有的Model.
 *
 *
 */
class QProjectModel : public QAbstractItemModel
{
    Q_OBJECT

public:
    explicit QProjectModel(QObject *parent = nullptr);

    // Header:
    QVariant headerData(int section,
                        Qt::Orientation orientation,
                        int role = Qt::DisplayRole) const override;

    // Basic functionality:  获取子元素的索引.
    QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
    QModelIndex parent(const QModelIndex &index) const override;

    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
    int columnCount(const QModelIndex &parent = QModelIndex()) const override;

    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
    ProjectModel *getItem(const QModelIndex &index) const;
    //添加设置数据.
    bool setData(const QModelIndex &index,  ProjectModel &value, int role = Qt::EditRole);

    void appendRow(ProjectModel *model);
   // std::unique_ptr<ProjectModel> rootItem;
    ProjectModel * rootItem;
private:
};

#endif // QPROJECTMODEL_H
